package tcln.sors.client.main;

import tcln.sors.client.contact.ContactModelData;
import tcln.sors.client.contact.ProductModelData;
import tcln.sors.client.core.mvc.DefaultModelData;
import tcln.sors.client.core.mvc.ListModelData;
import tcln.sors.client.core.mvc.ModelData;
import tcln.sors.client.order.OrderModelData;

/**
 * Model data for the main screen.
 * 
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
public class MainScreenModelData extends DefaultModelData<MainScreenModelData> {
    private static final String PROPERTY_SEARCH_MODEL_DATA = "searchModelData";
    private static final String PROPERTY_ORDER_SUMMARY_MODEL_DATA = "orderSummaryModelData";
    private static final String PROPERTY_ORDER_MODEL_DATA = "orderModelData";
    private static final String PROPERTY_CONTACT_MODEL_DATA = "contactModelData";
    private static final String PROPERTY_PRODUCT_MODEL_DATA = "productModelData";

    /**
     * Returns current model data for all products loaded for searching.
     * 
     * @return
     */
    @SuppressWarnings("unchecked")
    public ListModelData<ProductModelData> getProductModelData() {
        return get(PROPERTY_PRODUCT_MODEL_DATA, ListModelData.class);
    }

    /**
     * Sets new model data for all products loaded for searching.
     * 
     * @param productModelData
     */
    public void setProductModelData(ListModelData<ProductModelData> productModelData) {
        set(PROPERTY_PRODUCT_MODEL_DATA, productModelData);
    }

    /**
     * Returns current model data for all contacts loaded for searching.
     * 
     * @return
     */
    @SuppressWarnings("unchecked")
    public ListModelData<ContactModelData> getContactModelData() {
        return get(PROPERTY_CONTACT_MODEL_DATA, ListModelData.class);
    }

    /**
     * Sets new model data for all contacts loaded for searching.
     * 
     * @param contactModelData
     */
    public void setContactModelData(ListModelData<ContactModelData> contactModelData) {
        set(PROPERTY_CONTACT_MODEL_DATA, contactModelData);
    }

    /**
     * Returns current value of a list model data for all displaying orders.
     * 
     * @return
     */
    @SuppressWarnings("unchecked")
    public ListModelData<OrderModelData> getOrderModelData() {
        return get(PROPERTY_ORDER_MODEL_DATA, ListModelData.class);
    }

    /**
     * Sets new list model data for all displaying orders.
     * 
     * @param orderModelData
     */
    public void setOrderModelData(ListModelData<OrderModelData> orderModelData) {
        set(PROPERTY_ORDER_MODEL_DATA, orderModelData);
    }

    /**
     * Returns current value of model data which contains all summary about all orders in the system.
     * 
     * @return
     */
    public ModelData<?> getOrderSummaryModelData() {
        return get(PROPERTY_ORDER_SUMMARY_MODEL_DATA, ModelData.class);
    }

    /**
     * Sets new model data which contains all summary about all orders in the system.
     * 
     * @param orderSummaryModelData
     */
    public void setOrderSummaryModelData(ModelData<?> orderSummaryModelData) {
        set(PROPERTY_ORDER_SUMMARY_MODEL_DATA, orderSummaryModelData);
    }

    /**
     * Returns current value of model data holding all search criteria.
     * 
     * @return
     */
    public ModelData<?> getSearchModelData() {
        return get(PROPERTY_SEARCH_MODEL_DATA, ModelData.class);
    }

    /**
     * Sets new model data holding all search criteria.
     * 
     * @param searchModelData
     */
    public void setSearchModelData(ModelData<?> searchModelData) {
        set(PROPERTY_SEARCH_MODEL_DATA, searchModelData);
    }
}
